package me.w70.bot.util;

import java.util.Random;

public class Maths {
	public static int min(int... nums) {
		int min = Integer.MAX_VALUE;
		for (int i : nums) {
			if (i < min) {
				min = i;
			}
		}
		return min;
	}

	public static int max(int... nums) {
		int max = -1 * Integer.MAX_VALUE;
		for (int i : nums) {
			if (i > max) {
				max = i;
			}
		}
		return max;
	}

	public static int randomBetween(int min, int max) {
		Random rand = new Random();

		// nextInt is normally exclusive of the top value,
		// so add 1 to make it inclusive
		int randomNum = rand.nextInt(max - min + 1) + min;
		return randomNum;
	}

	public static int toInt(Object o) {
		if (o instanceof Integer) {
			return (int) ((Integer) o);
		}
		return -1;
	}

	public static boolean isNumber(char l) {
		try {
			int n = Integer.parseInt(Character.toString(l));

			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public static double randomDouble() {
		Random rand = new Random();

		double randomNum = rand.nextDouble();
		return randomNum;
	}
}
